package com.example.Dao;

import com.example.entity.Goods;
import com.example.entity.Users;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface UserDao {
    @Select("select * from users")
    ArrayList<Users> queryAll();

    @Delete("delete from users where uID = #{uID}")
    int deleteByID(Integer uID);

    @Select("select * from users where uID = #{uID}")
    Users findById(Integer uID);

    @Update("UPDATE users SET uId = #{users.uid}," +
            "uName = #{users.uname}," +
            "uPwd = #{users.upwd}," +
            "uSex = #{users.usex}," +
            "uBirth = #{users.ubirth}," +
            "uCity = #{users.ucity}," +
            "uPhone = #{users.uphone}," +
            "uEmail =  #{users.uemail}," +
            "uQQ = #{users.uqq}," +
            "uCredit = #{users.ucredit} WHERE uID =  #{users.uid}")
    int update(@Param("users") Users users);

    @Insert("INSERT INTO users" +
            "(uID,uName,uPwd,uSex,uBirth,uCity,uPhone,uEmail,uQQ,uCredit,uImage)" +
            "VALUES(#{users.uid},#{users.uname},#{users.upwd},#{users.usex}" +
            ",#{users.ubirth},#{users.ucity},#{users.uphone},#{users.uemail},#{users.uqq},#{users.ucredit},#{users.uimage})")
    int insert(@Param("users") Users users);

    @Select("select * from users where uid = #{uID}")
    Users foundByID(Integer uID);

}
